<template>
<div class="demo">  
  <h2>你好我是Demo2组件！</h2> <br>
  <h3>收到的数据是：{{name}}</h3>
</div>
</template>

<script>
  export default {
    mounted(){
     this.$bus.$on('getDataFromDemo1',this.getDataFromDemo1);
     //关闭事件
     // this.$bus.$off('getDataFromDemo1');
   },
   data(){
     return{
      name:''  
     }
   },
   methods:{
     getDataFromDemo1(name){
       this.name = name;
     }
   }
  }
</script>

<style scoped>
    .demo{
        background-color: gray;
        padding: 10px;
    }
</style>